package cn.hhchat.wp.repository;

import cn.hhchat.wp.entity.PostEntity;
import cn.hhchat.wp.entity.GroupEntity;
import cn.hhchat.wp.entity.UserEntity;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Date;
import java.util.List;

/**
 * Created this one by HMH on 2017/10/23.
 */
public interface PostRepository extends JpaRepository<PostEntity, Long> {

    int countByWeekOfYearAndYearAndGroupOrderByCreateTimeDesc(int week, int year, GroupEntity group);

    List<PostEntity> findByWeekOfYearAndYearAndGroupOrderByCreateTimeDesc(int week, int year , GroupEntity group);

    List<PostEntity> findByWeekOfYearAndYearAndGroupAndPosterOrderByCreateTimeDesc(int week, int year , GroupEntity group, UserEntity user);

    List<PostEntity> findTop5ByGroupAndPosterOrderByCreateTimeDesc(GroupEntity group, UserEntity user);
}

